package com.team.app;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;

import javax.imageio.ImageIO;

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;


public class Image2Base64 {
	 
	public static void main(String args[]) {
	try{
	      BufferedImage image = ImageIO.read(new File("E:/background/IMG_0360.jpg"));
	      ByteArrayOutputStream baos = new ByteArrayOutputStream();
	      ImageIO.write(image, "png", baos);
	      byte[] res=baos.toByteArray();
	      String encodedImage = Base64.encode(res);
	      System.out.println(encodedImage);
	} 
	catch(Exception e) {
	     e.printStackTrace();
	     System.out.println("Some problem has occurred. Please try again");
	}
	}
}
